﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Bitirme.Controllers;

namespace Bitirme.Views
{
    public partial class ShowEmployees : System.Web.UI.Page
    {
        private EmployeeHandler employeeHandler;

        protected void Page_Load(object sender, EventArgs e)
        {
            
        }
         protected void GridView1_OnRowCommand(object sender, GridViewCommandEventArgs e)
        {

            int rowNum = int.Parse(e.CommandArgument.ToString()); 
            string choice = e.CommandName;
            string iD = GridView1.Rows[rowNum].Cells[0].Text;

            employeeHandler = new EmployeeHandler();

            if (choice == "update")
                Response.Redirect("UpdateEmployee.aspx?id=" + iD);
            else if (choice == "delete")
            {
                employeeHandler.DeleteEmployeeToCapabilityByEmployeeID(int.Parse(iD));
                employeeHandler.DeleteEmployeeByEmployeeID(int.Parse(iD));
                Response.Redirect("ShowEmployees.aspx");
            }
            else if (choice == "select") {
                Response.Redirect("ShowEmployee.aspx?id=" + iD);
            }
        }
    }
}